<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>{$Think.config.site.title} - 登录</title>
	
  <meta name="keywords" content="{$Think.config.site.keywords}">
  <meta name="description" content="{$Think.config.site.description}">
  <link type="text/css" rel="stylesheet" href="{$Think.config.site.resource_url}css/sign.css" />
</head>
<body>
    <div class="pages">
      <div class="content">
      <div class="login-header">
            <!--<img src="{$Think.config.site.resource_url}images/login/logo.png">-->
			<p>{$Think.config.site.title}</p>
      </div>
      <div class="tabPanel">
      <div class="nav">
        <ul id="nav" style="padding-left: 0px;">
          <a href="javascript:void(0)" class="active">账号密码登录</a>
        </ul>
      </div>
      <div class="panes">
          <div class="pane" style="display: block;">
            <div class="login-input-box">
                  <span class="icon icon-password"></span>
                  <input type="text" placeholder="请输入用户名" id="username" required value="">
            </div>
            <div class="login-input-box">
                  <span class="icon icon-user"></span>
                  <input type="password" placeholder="请输入密码" id="password" required>
            </div>
            <div class="login-button-box" id="submit"></div>
          </div>
      </div>
      </div>
      <div class="copyright">
        <p>{$Think.config.site.copyright}</p>
      </div>
      </div>
    </div>
    <script src="{$Think.config.site.resource_url}js/jquery.min.js?v=2.1.4"></script>
    <script type="text/javascript">
      $('.tabPanel ul a').click(function(){
        $(this).addClass('active').siblings().removeClass('active');
        $('.panes>.pane:eq('+$(this).index()+')').show().siblings().hide(); 
      });
    </script>
    <script src="{$Think.config.site.resource_url}js/bootstrap.min.js?v=3.3.5"></script>
  <script src="{$Think.config.site.resource_url}js/plugins/layer/layer.js"></script>
  <script>
$(document).ready(function(){
  $("#submit").bind('click',function(){
     doLogin();
  })
  $("#password").bind('keyup',function(e){
     var key = e.which;
     if( 13 == key ) {
      doLogin();
     }
  })
  function doLogin(){
    var username = $("#username").val();
    if(username == '') {
       $("#username").attr('placeholder','请输入用户名');
      $("#username").focus();
      return false;
    }
    var password = $("#password").val();
    if(password == '' ) {
       $("#password").attr('placeholder','请输入密码');
      $("#password").focus();
      return false;
    }
    $.ajax({
      type : 'POST',
      url : '<?php echo \think\Request::instance()->root(); ?>/ausadmin/Login',
      dataType : 'json',
      data : {username : username, password : password},
      success : function(result) {
        if(0 === result.code) {
          location.href = result.url;
        } else if ( -1000 === result.code) {
          //帐号不存在
          $("#username").val("");
          $("#username").attr('placeholder','你输入的账号有误，请重新输入');
          $("#username").focus();
        }else if ( -1001 === result.code) {
          //帐号不存在
          $("#username").val("");
          $("#username").attr('placeholder','你输入的账号有误，请重新输入');
          $("#username").focus();
        } else if ( -1010 === result.code) {
          //密码错误
          $("#password").val("");
          $("#password").attr('placeholder','密码错误，请重新输入');
          $("#password").focus();
        } else  {
          //密码错误
          $("#password").val("");
          $("#password").attr('placeholder','密码错误，请重新输入');
          $("#password").focus();
        }
      },
      error : function(){
        //layer.close(layer1);
        layer.msg('服务器错误！请稍后重试', {icon: 2});
      }
    })
  };
  {notempty name='$Think.cookie.username'}
  $("#password").focus();
  {/notempty}
})
</script>
</body>
</html>